﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Profile;
using System.Web.Security;
using SDT.Lib.Common;

namespace SDT.Model
{
    public class UserProfile : ProfileBase
    {
        [SettingsAllowAnonymous(false)]
        public string Email
        {
            get { return base["Email"] as string; }
            set { base["Email"] = value; }
        }

        [SettingsAllowAnonymous(false)]
        public string FullName
        {
            get { return base["FullName"] as string; }
            set { base["FullName"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string Address
        {
            get { return base["Address"] as string; }
            set { base["Address"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string Company
        {
            get { return base["Company"] as string; }
            set { base["Company"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string Phone
        {
            get { return base["Phone"] as string; }
            set { base["Phone"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string NicYahoo
        {
            get { return base["NicYahoo"] as string; }
            set { base["NicYahoo"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string NicSkype
        {
            get { return base["NicSkype"] as string; }
            set { base["NicSkype"] = value; }
        }
        public string NicMSN
        {
            get { return base["NicMSN"] as string; }
            set { base["NicMSN"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string ProfessionID
        {
            get { return base["ProfessionID"] as string; }
            set { base["ProfessionID"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string ProfessionName
        {
            get { return base["ProfessionName"] as string; }
            set { base["ProfessionName"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string OrgnizationName
        {
            get { return base["OrgnizationName"] as string; }
            set { base["OrgnizationName"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string DepartmentName
        {
            get { return base["DepartmentName"] as string; }
            set { base["DepartmentName"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string OrgnizationID
        {
            get { return base["OrgnizationID"] as string; }
            set { base["OrgnizationID"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string DepartmentID
        {
            get { return base["DepartmentID"] as string; }
            set { base["DepartmentID"] = value; }
        }
        [SettingsAllowAnonymous(false)]
        public string EmployeeID
        {
            get { return base["EmployeeID"] as string; }
            set { base["EmployeeID"] = value; }
        }

        [SettingsAllowAnonymous(false)]
        public string Description
        {
            get { return base["Description"] as string; }
            set { base["Description"] = value; }
        }

        public static UserProfile GetUserProfile(string username)
        {
            return Create(username, true) as UserProfile;
        }

        public static UserProfile GetUserProfile()
        {
            return Create(Membership.GetUser().UserName) as UserProfile;
        }
        public static UserProfile GetUserProfile(bool btl)
        {
            return Create(Membership.GetUser().Email) as UserProfile;
        }
        public static Array GetCurrentUser()
        {
            string[] info = new string[2];
            info[0] = Membership.GetUser().UserName;
            info[1] = Membership.GetUser().Email;
            return info;
        }
        public static int GetOrganizationID()
        {
            var p = GetUserProfile();
            if (p != null)
            {
                if (p.OrgnizationID == null || p.OrgnizationID == string.Empty) return 0;
                else
                    return Utils.ParseInt(p.OrgnizationID);
            }
            else return 0;
        }
        public static int GetDepartmentID()
        {
            var p = GetUserProfile();
            if (p != null)
            {
                if (p.DepartmentID == null || p.DepartmentID == string.Empty) return 0;
                else
                    return Utils.ParseInt(p.DepartmentID);
            }
            else return 0;
        }
        public static int GetEmployeeID()
        {
            var p = GetUserProfile();
            if (p != null)
            {
                if (p.EmployeeID == null || p.EmployeeID == string.Empty) return 0;
                else
                    return Utils.ParseInt(p.EmployeeID);
            }
            else return 0;
        }

    }
}
